package manage.actions;

import java.io.InputStream;

import org.apache.commons.lang3.StringUtils;

import manage.commons.Constants;
import manage.commons.interceptors.CurrentWorkerAware;
import manage.modules.worker.model.Worker;
import manage.modules.worker.model.WorkerInfo;

/**
 * 判断是需要更新还是新增
 * 
 * @author dongji
 * 
 */
public class ManageAction extends BaseAction implements CurrentWorkerAware {

	private static final long serialVersionUID = 9020767545273771611L;
	protected String action;
	protected String operationType;
	protected InputStream inputStream;
	protected WorkerInfo currentWorker;

	public String forwardAddOrUpdatePage() {
		return SUCCESS;
	}

	public String getAction() {
		return action;
	}

	public void setOperationType(String operationType) {
		this.operationType = operationType;
	}

	public String getOperationType() {
		return operationType;
	}

	public boolean isAddOperater() {
		return Constants.OPEREATE_INSERT.equals(operationType) ? true : false;
	}

	public boolean isUpdateOperater() {
		return Constants.OPEREATE_UPDATE.equals(operationType) ? true : false;
	}

	public boolean isSuperManager() {
		return StringUtils.equals(Constants.SUPERMANAGER, (String) request
				.getSession().getAttribute(Constants.SUPERMANAGER_KEY));
	}

	public InputStream getInputStream() {
		return inputStream;
	}

	public void setInputStream(InputStream inputStream) {
		this.inputStream = inputStream;
	}

	public Worker getCurrentWorker() {
		return currentWorker;
	}

	@Override
	public void setCurrentWorker(WorkerInfo currentWorker) {
		this.currentWorker = currentWorker;
	}
}
